package com.ticket.service.impl;

import com.ticket.dao.CollectDao;
import com.ticket.entity.Collect;
import com.ticket.entity.CollectCount;
import com.ticket.service.CollectService;
import com.ticket.util.MybatisUtil;
import com.ticket.util.Page;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @author 全谢民
 * @version 8.0
 * @description: TODO   用户收藏
 * @date 2023/10/12 9:08
 */
public class CollectServiceImpl implements CollectService {
    static CollectDao cd;

    static {
        SqlSession sqlSession = MybatisUtil.getSqlSession();
        cd = sqlSession.getMapper(CollectDao.class);
    }

    /*
     * @author 全谢民
     * @description TODO 前端首页 根据用户收藏判断
     * @date 2023/10/12 9:09
     */
    @Override
    public CollectCount selCount(CollectCount count) {
        CollectCount byCount = cd.selectCollectCountList(count);
        return byCount;
    }
    /*
     * @author 全谢民
     * @description TODO    查询用户收藏--视图查询
     * @date 2023/10/15 16:41
     */
    @Override
    public Page<Collect> selUserCollectList(Collect collect, Page<Collect> page) {
        List<Collect> dataList = cd.selUserCollectList(collect,page);
        int count = cd.selUserCollectListCount(collect);
        page.setDataList(dataList);
        page.setCurrPageNo(count);
        return page;
    }

    /*
     * @author 全谢民
     * @description TODO 用户删除个人收藏
     * @date 2023/10/16 14:21
     */
    @Override
    public int delUserCollect(int collectId) {
        return cd.delUserCollect(collectId);
    }


}
